home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Memory / Queues / FiniteQueueBase.h < prev   
Encoding:
Text File  |  1997-06-28  |  802 b   |  40 lines  |  [TEXT/CWIE]

  1. // FiniteQueueBase.h
  2.  
  3. #ifndef FiniteQueueBase_h
  4. #define FiniteQueueBase_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9.  
  10. class FiniteQueueBase
  11.   {
  12.     private:
  13.         uint8 *const start;
  14.         uint8 *const end;
  15.         const uint32 elementSize;
  16.         const uint32 length;
  17.         
  18.         uint8 *allocateNext;
  19.         uint8 *disposeNext;
  20.         uint32 allocated;
  21.         
  22.         // not implemented:
  23.             FiniteQueueBase( const FiniteQueueBase& );
  24.             void operator=( const FiniteQueueBase& );
  25.         
  26.     public:
  27.         FiniteQueueBase( void *theSpace, uint32 length, uint32 elementSize );
  28.         
  29.         bool Full() const            { return allocated >= length; }
  30.         bool IsEmpty() const        { return allocated == 0; }
  31.  
  32.         void *Allocate( uint32 size );
  33.         void Release( void * );
  34.   };
  35.  
  36. inline void *operator new( uint32 size, FiniteQueueBase& pool )
  37.     { return pool.Allocate( size ); }
  38.  
  39. #endif
  40.